//
//  CustomProgressView.m
//  HundPark
//
//  Created by Aguilar Rolando on 2013-04-22.
//  Copyright (c) 2013 ARV IT. All rights reserved.
//


#import "CustomProgressView.h"
#import "UIFont+HundPark.h"

@interface CustomProgressView ()
@property (strong,nonatomic)UILabel *titleLabel;
@end

#define IMAGEWIDTH 305
#define IMAGEHEIGHT 190

@implementation CustomProgressView

@synthesize titleLabel = _titleLabel;
@synthesize titleText =_titleText;
@synthesize activityIndicator = _activityIndicator;

-(NSString *)titleText
{
    if(!_titleText)
    {
        _titleText = @"In Progress, please Wait.";
    }
    
    return _titleText;
}

-(void)setTitleText:(NSString *)titleText
{
    self.titleLabel.text = titleText;
}

-(UILabel *)titleLabel
{
    if (!_titleLabel) {
        //Add Label
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,IMAGEWIDTH,IMAGEHEIGHT)];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.textColor = [UIColor whiteColor];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [_titleLabel setFont:[UIFont dogParkH1]];
        [_titleLabel setNumberOfLines:0];
    }
    
    return _titleLabel;
}

-(UIActivityIndicatorView *)activityIndicator
{
    if (!_activityIndicator) {
        _activityIndicator = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(0,0,IMAGEWIDTH,IMAGEHEIGHT)];
    }
    return _activityIndicator;
}

- (id)init
{
    self = [super init];
    if (self) {
        // Initialization code
        self.image = [UIImage imageNamed:@"progressView.png"];
        float xStartPostion = [[UIScreen mainScreen] bounds].size.width/2-IMAGEWIDTH/2;
        float yStartPostion = [[UIScreen mainScreen] bounds].size.height/2-IMAGEHEIGHT;
        
        //Adjust X,Y,W,H as needed
        [self setFrame:CGRectMake(xStartPostion,yStartPostion,IMAGEWIDTH,IMAGEHEIGHT)];
        [self addSubview:self.titleLabel];
        [self addSubview:self.activityIndicator];
        
    }
    return self;
}

@end
